﻿//Write a program that gets a number n and after that gets more n numbers and calculates and prints their sum. 

using System;

class SumNNumbers
{
    static void Main()
    {
        Console.Write("Enter number count: ");
        string numberCountString = Console.ReadLine();
        int numberCount;
        if (int.TryParse(numberCountString, out numberCount))
        {
            double number;
            double numberSum = 0;
            for (int i = 1; i <= numberCount; i++)
            {
                Console.Write("Enter number N{0} = ", i);
                string numberString = Console.ReadLine().Replace(".", ",");
                while (!double.TryParse(numberString, out number))
                {
                    Console.Write("Not a valid number, try again. N{0} = ", i + 1);
                    numberString = Console.ReadLine().Replace(".", ",");
                }
                numberSum = numberSum + number;
            }
            Console.WriteLine("The Sum of these {0} numbers is: {1}", numberCount, numberSum);
        }
        else
            Console.WriteLine("Not a valid number.");
    }
}
